package br.com.caelum.vraptor.controller;

import java.util.List;

import javax.inject.Inject;

import br.com.caelum.vraptor.Controller;
import br.com.caelum.vraptor.Result;
import br.com.caelum.vraptor.dao.GenericDAO;
import br.com.caelum.vraptor.entidades.Professor;

@Controller
public class ProfessorController {
	

	@Inject
    private Result result;
    
    @Inject
    private GenericDAO<Professor> dao;
    
    public void add(){
            
    }

    public List<Professor> list(){
            return dao.find();
    }
   
    public void save(Professor professor){
            dao.save(professor);
            result.redirectTo(this).list();
    }

    public Professor edit(int id){
        return dao.find(id);
    }

    public void delete(int id){
    	Professor professor= new Professor();
        professor.setId(id);
        dao.delete(professor);
        result.redirectTo(this).list();
    }

	
}
